package com.ibiaoke.order.service;

import com.ibiaoke.common.base.Page;
import com.ibiaoke.goods.dao.XcxGoodsDao;
import com.ibiaoke.goods.dao.XcxReduceGoodsDao;
import com.ibiaoke.goods.dao.XcxReduceGoodsDetailDao;
import com.ibiaoke.goods.dao.XcxShopPriceDao;
import com.ibiaoke.goods.entity.XcxReduceGoodsDetail;
import com.ibiaoke.goods.entity.vo.MarketVo;
import com.ibiaoke.order.dao.XcxOrderDao;
import com.ibiaoke.system.dao.ShopDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class MarketServiceImpl implements MarketService {
    @Autowired
    private ShopDao shopDao;
    @Autowired
    private XcxReduceGoodsDetailDao xcxReduceGoodsDetailDao;
    @Autowired
    private XcxGoodsDao xcxGoodsDao;
    @Autowired
    private XcxReduceGoodsDao xcxReduceGoodsDao;
    @Autowired
    private XcxShopPriceDao xcxShopPriceDao;
    @Autowired
    private XcxOrderDao xcxOrderDao;


    @Override
    public List<MarketVo> marketList(MarketVo marketVo, Page page){
        //根据条件查询线下销售情况
        List<XcxReduceGoodsDetail> xcxReduceGoodsDetailList=xcxReduceGoodsDetailDao.marketXcxReduceGodsDetail(marketVo, page);
        //封装给前端页面的集合
        List<MarketVo> MarketVoList = new ArrayList<MarketVo>();
        //给集合set值
        for (XcxReduceGoodsDetail xrg:xcxReduceGoodsDetailList) {
            MarketVo m = new MarketVo();
            //商品编号
            m.setGoodsId(xrg.getGoodsId());
            //商品名称
            m.setGoodsName(xrg.getGoodsName());
            //销售时间
            m.setCreateTime(xrg.getCreateTime());
            //数量
            m.setNum(xrg.getNum());
            //单位
            m.setSpec(xrg.getGoodsSpec());
            //总金额
            m.setOrderPrice(xrg.getPrice());
            //单价
            m.setPrice(xrg.getOnePrice());
            //店铺
            m.setShopName(xrg.getShopName());
            //放进集合
            MarketVoList.add(m);
        }


        //根据条件查询线上销售情况,需要购物车系统完善之后进行统计
        /*xcxOrderDao.getXcxOrderBySale(marketVo,page);*/

        return MarketVoList;
    }
}